package com.dayuanit.dy8.model.sigle.proxy.dynamic;

import java.lang.reflect.Proxy;

public class Test {
    public static void main(String[] args) {
        UserService userService1 = new UserServiceImpl();
        userService1.saveUser();

        System.out.println("------------------");
        UserService userService2 = (UserService) Proxy.newProxyInstance(UserService.class.getClassLoader(),
                new Class[]{UserService.class},
                new MyInvocationHandler(new UserServiceImpl()));
        System.out.println(userService2.getClass().getName());

        // CGLIB动态代理  JDK动态代理

        userService2.saveUser();

//        userService2.delUser();
    }
}
